﻿#pragma once

#include <QWidget>
#include "ui_MiniMapMaskWidget.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MiniMapMaskWidgetClass; };
QT_END_NAMESPACE

class GraphicsScene;

class MiniMapMaskWidget : public QWidget
{
	Q_OBJECT

public:
	MiniMapMaskWidget(QWidget* parent = nullptr);
	~MiniMapMaskWidget();
	void setVisableRect(const QRect& rect);
	void setScene(GraphicsScene* scene);
signals:
	void sigCenterMove(const QPoint& point);
private:
	QImage renderImage();
protected:
	virtual void paintEvent(QPaintEvent* event)override;
	virtual void mouseMoveEvent(QMouseEvent* event) override;
	virtual void mousePressEvent(QMouseEvent* event) override;
	virtual void mouseReleaseEvent(QMouseEvent* event) override;
private:
	// 调整可见矩形框
	void adjustRect(const QRect& rect);
private:
	Ui::MiniMapMaskWidgetClass* ui;
	QRect m_visableRect;
	// 鼠标按下时候的坐标
	QPoint m_pressPoint;
	// 鼠标按下时候的矩形框
	QRect m_pressRect;
	// 鼠标按下是否在矩形框
	bool m_isPressRect = false;
	// 画笔宽度
	const int m_penWidth = 3;
	GraphicsScene* m_scene = nullptr;
};
